from flask import jsonify


class Result(object):
    def __init__(self, code=0, msg='', data=[]):
        self.code = code
        self.msg = msg
        self.data = data
    # 返回json字符串
    def ToJson(self):
        tmp = {}
        tmp['code'] = self.code
        tmp['error_msg'] = self.msg
        tmp['data'] = self.data
        return jsonify(tmp)


def result(success=1, error_code=None, error_msg=None, data=[]):
    rdic = {}
    rdic["success"] = success
    rdic["error_code"] = error_code
    rdic["error_msg"] = error_msg
    rdic["data"] = data
    return jsonify(rdic)
